<div class="layui-fluid nepadmin-pad0 nepadmin-mar0 list0" id="drawingsset" lay-title="违约金设置">
  <div class="layui-fluid layui-form">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card layui-tab layui-tab-brief">
        	<ul class="layui-tab-title">
			  <li class="layui-this" value="1">违约金设置</li>
			  <li value="2">代理佣金设置</li>
			  <li value="3">会员分红设置</li>
			  <li value="4">提款设置</li>
			  <li value="5">充值设置</li>
			</ul>
			<div class="layui-card-body layui-tab-content hxr-card-body" style="padding: 15px;">
			  <div class="layui-tab-item layui-show">
				  <div class=" layui-form">
			  <form id="break_set" lay-filter="aa">
					<div class="layui-form-item">
				  <label class="layui-form-label">违约金额</label>
				  <div class="layui-input-inline">
					<input type="number" v-model="detail.value" autocomplete="off" lay-verify="required" class="layui-input" placeholder="请输入金额">
				  </div>
				</div>
				<div class="layui-form-item">
				  <label class="layui-form-label">是否启用</label>
				  <div class="layui-input-inline">
					 <div class="layui-unselect layui-form-switch" :class="{'layui-form-onswitch':detail.status==1}" lay-skin="_switch" @click="radioF()"><em>{{detail.status==1?'启用':'停用'}}</em><i></i></div>
				  </div>
				</div>
				<div class="layui-form-item">
				  <label class="layui-form-label"></label>
				  <div class="layui-input-inline">
					<button type="button" class="layui-btn" lay-submit style="width: 190px;" lay-filter="form-break">保存</button>
				  </div>
				</div>
			  	</form>
				  </div>
			  </div>
			  <div class="layui-tab-item">
			  <form id="commission">
				<div class="layui-form-item">
				  <label class="layui-form-label">佣金比例</label>
				  <div class="layui-input-inline">
					<input type="number" style="display: inline-block;width: 90%;" v-model="detail.key_value" autocomplete="off" lay-verify="required" class="layui-input" placeholder="请输入佣金比例">%
				  </div>
				</div>
				<div class="layui-form-item">
				  <label class="layui-form-label">是否启用</label>
				  <div class="layui-input-inline">
					 <div class="layui-unselect layui-form-switch" :class="{'layui-form-onswitch':detail.status==1}" lay-skin="_switch" @click="radioF()"><em>{{detail.status==1?'启用':'停用'}}</em><i></i></div>
				  </div>
				</div>
				<div class="layui-form-item">
				  <label class="layui-form-label"></label>
				  <div class="layui-input-inline">
					<button type="button" class="layui-btn" lay-submit style="width: 190px;" lay-filter="form-commission">保存</button>
				  </div>
				</div>
			  	</form>
			  </div>
			  <div class="layui-tab-item">
			  <form id="benefit">
				<div class="layui-form-item">
				  <label class="layui-form-label">分红比例</label>
				  <div class="layui-input-inline">
					<input type="number" style="display: inline-block;width: 90%;" v-model="detail.key_value" autocomplete="off" lay-verify="required" class="layui-input" placeholder="请输入分红比例">%
				  </div>
				</div>
				<div class="layui-form-item">
				  <label class="layui-form-label">是否启用</label>
				  <div class="layui-input-inline">
					 <div class="layui-unselect layui-form-switch" :class="{'layui-form-onswitch':detail.status==1}" lay-skin="_switch" @click="radioF()"><em>{{detail.status==1?'启用':'停用'}}</em><i></i></div>
				  </div>
				</div>
				<div class="layui-form-item">
				  <label class="layui-form-label"></label>
				  <div class="layui-input-inline">
					<button type="button" class="layui-btn" lay-submit style="width: 190px;" lay-filter="form-benefit">保存</button>
				  </div>
				</div>
			  	</form>
			  </div>
			  <div class="layui-tab-item">
			  <form id="drawset">
				<div class="layui-form-item verify">
				  <label class="layui-form-label">单笔提款最小金额(元)</label>
				  <div class="layui-input-block layui-input-inline">
					<input type="number" v-model="detail.value.min_money" autocomplete="off" verify="require|znum" class="layui-input" placeholder="请输入最小金额">
					<span class="hint">单笔提款最小金额必填</span>
				  </div>
				  <div class="layui-form-mid layui-word-aux">为0时不做限制</div>
				</div>
				<div class="layui-form-item verify">
				  <label class="layui-form-label">单笔提款最大金额(元)</label>
				  <div class="layui-input-block layui-input-inline">
					<input type="number" v-model="detail.value.max_money" autocomplete="off" verify="require|znum" class="layui-input" placeholder="请输入最大金额">
					<span class="hint">单笔提款最大金额必填</span>
				  </div>
				  <div class="layui-form-mid layui-word-aux">为0时不做限制</div>
				</div>
				<div class="layui-form-item verify">
				  <label class="layui-form-label">当日提款总金额(元)</label>
				  <div class="layui-input-block layui-input-inline">
					<input type="number" v-model="detail.value.count_money" autocomplete="off" verify="require|znum" class="layui-input" placeholder="请输入总金额">
					<span class="hint">当日提款总金额必填</span>
				  </div>
				  <div class="layui-form-mid layui-word-aux">为0时不做限制</div>
				</div>
				<div class="layui-form-item verify">
				  <label class="layui-form-label">当日提款总次数</label>
				  <div class="layui-input-block layui-input-inline">
					<input type="number" v-model="detail.value.count_num" autocomplete="off" verify="require|znum" class="layui-input" placeholder="请输入总次数">
					<span class="hint">当日提款总次数必填</span>
				  </div>
				  <div class="layui-form-mid layui-word-aux">为0时不做限制</div>
				</div>
				<div class="layui-form-item verify">
				  <label class="layui-form-label">单笔提款手续费(元)</label>
				  <div class="layui-input-block layui-input-inline">
					<input type="number" v-model="detail.value.fee" autocomplete="off" verify="require|znum" class="layui-input" placeholder="请输入手续费">
					<span class="hint">单笔提款手续费必填</span>
				  </div>
				</div>
				<div class="layui-form-item">
				  <label class="layui-form-label">是否启用</label>
				  <div class="layui-input-inline">
					 <div class="layui-unselect layui-form-switch" :class="{'layui-form-onswitch':detail.status==1}" lay-skin="_switch" @click="radioF()"><em>{{detail.status==1?'启用':'停用'}}</em><i></i></div>
				  </div>
				</div>
				<div class="layui-form-item">
				  <label class="layui-form-label"></label>
				  <div class="layui-input-inline">
					<button type="button" class="layui-btn" style="width: 190px;" @click="submit">保存</button>
				  </div>
				</div>
			  	</form>
			  </div>
			  <div class="layui-tab-item">
			  <form id="recharge">
					<div class="layui-form-item">
					  <label class="layui-form-label">充值金额</label>
					  <div class="layui-input-inline flex" style="width: 500px;">
						<input style="margin-right: 30px;" type="number" v-model="full" autocomplete="off" name="username" class="layui-input" placeholder="充值金额">
						<!-- <input style="margin-right: 30px;" type="number" v-model="reduce" autocomplete="off" name="username" class="layui-input" placeholder="赠送金额"> -->
						<button type="button" class="layui-btn" @click="add">添加</button>
					  </div>
					</div>
					<div class="layui-form-item" v-if="detail.value.length">
					  <label class="layui-form-label">已设置金额</label>
					  <div class="layui-input-inline" style="width: 500px;">
						<table class="layui-table">
						    <thead>
						      <tr>
						        <th>充值金额</th>
						        <!-- <th>赠送金额</th> -->
						        <th>操作</th>
						      </tr> 
						    </thead>
						    <tbody>
						      <tr v-for="(x,index) in detail.value">
						        <td>{{x.full}}</td>
		
						        <!-- <td>{{x.reduce}}</td> -->
						        <td>
									<a class="layui-btn layui-btn-danger layui-btn-xs" @click="del(index)"><i class="layui-icon layui-icon-delete"></i>删除</a>
								</td>
						      </tr>
						    </tbody>
						  </table>
					  </div>
					</div>
					<div class="layui-form-item">
					  <label class="layui-form-label">描述</label>
					  <div class="layui-input-inline" style="width: 500px;">
					      <textarea type="text" class="layui-textarea" v-model="detail.description" verify='require'></textarea>
					  </div>
					</div>
					<div class="layui-form-item">
					  <label class="layui-form-label">是否自定义充值金额</label>
					  <div class="layui-input-inline flex" style="width: 500px;">
						 <div class="layui-unselect layui-form-switch" :class="{'layui-form-onswitch':detail.status==0}" lay-skin="_switch" @click="radioF()"><em>{{detail.status==0?'是':'否'}}</em><i></i></div>
					  </div>
					</div>
					<div class="layui-form-item">
					  <label class="layui-form-label"></label>
					  <div class="layui-input-inline flex">
						<button type="button" class="layui-btn" style="width: 200px;" @click="save">保存</button>
					  </div>
					</div>
			  	</form>
			  </div>
			  </div>
		  <!-- <div class="layui-card-header">违约金设置</div>
          <div class="layui-card-body hxr-card-body" style="padding: 15px;">
          <div class="layui-tab-item layui-show">
			  <div class=" layui-form">
			  <form id="change_pwd" lay-filter="aa">
				<div class="layui-form-item">
				  <label class="layui-form-label">违约金额</label>
				  <div class="layui-input-inline">
					<input type="number" v-model="detail.value" autocomplete="off" lay-verify="required" class="layui-input" placeholder="请输入金额">
				  </div>
				</div>
				<div class="layui-form-item">
				  <label class="layui-form-label">是否启用</label>
				  <div class="layui-input-inline">
					 <div class="layui-unselect layui-form-switch" :class="{'layui-form-onswitch':detail.status==1}" lay-skin="_switch" @click="radioF()"><em>{{detail.status==1?'启用':'停用'}}</em><i></i></div>
				  </div>
				</div>
				<div class="layui-form-item">
				  <label class="layui-form-label"></label>
				  <div class="layui-input-inline">
					<button type="button" class="layui-btn" lay-submit style="width: 190px;" lay-filter="form-submit">保存</button>
				  </div>
				</div>
			 </form>
			 </div>
		 </div>
		<div class="layui-tab-item">
			  <form id="change_cash_pwd">
				  <div class=" layui-form">
			  	<div class="layui-form-item">
			  	  <label class="layui-form-label">当前提现密码</label>
			  	  <div class="layui-input-inline">
			  		<input type="password" name="before_cash_pwd"  lay-verify="required" autocomplete="off" class="layui-input">
			  	  </div>
			  	</div>
			  	<div class="layui-form-item">
			  	  <label class="layui-form-label">提现新密码</label>
			  	  <div class="layui-input-inline">
			  		<input type="password" name="after_cash_pwd" lay-verify="required" autocomplete="off" class="layui-input">
			  	  </div>
			  	</div>
			  	<div class="layui-form-item">
			  	  <label class="layui-form-label">确认提现新密码</label>
			  	  <div class="layui-input-inline">
			  		<input type="password" name="after_cash_pwd_confim" lay-verify="required" autocomplete="off" class="layui-input">
			  	  </div>
			  	</div>
			  	<div class="layui-form-item">
			  	  <label class="layui-form-label"></label>
			  	  <div class="layui-input-inline">
			  		<a class="layui-btn" lay-submit style="width: 200px;" lay-filter="go">保存</a>
			  	  </div>
			  	</div>
			  	</form>
			  </div> -->		
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<style type="text/css">
#drawingsset .layui-form-label{
	width: 150px;
}

	#break_set .layui-form-label{
		width: 150px;
	}
	#commission .layui-form-label{
		width: 150px;
	}	
	#benefit .layui-form-label{
		width: 150px;
	}	
	#drawset .layui-form-label{
		width: 150px;
	}	
	#recharge .layui-form-label{
		width: 150px;
	}	


</style>
<script>
	layui.use(['form'], function(){
	  var $ = layui.$
	  ,form = layui.form;
	  var vm=new Vue({
	  	  el:'#drawingsset',
	  	  data:{
	  		  detail:{
	  			 
	  		  },
	  		  old_detail:{}
	  	  },
	  	  mounted:function() {
			  //初始化
			  var _this=this;

              $("ul").on("click","li",function(){
            	  var a = $("layui-tab-title").val($(this).val());
                  alert(a);
              }
			  
	  	  	layui.admin.ajax('deposit/get_congfig',{},1).then(function(res){
				res.data.status?res.data.status:res.data.status=2;
				_this.detail=res.data,_this.old_detail=JSON.stringify(res.data);
	  	  	});

	  	  	layui.admin.ajax('withdraw/get_congfig',{},1).then(function(res){
				res.data.status?res.data.status:res.data.status=2;
				_this.detail=res.data,_this.old_detail=JSON.stringify(res.data);
	  	  	});
			//提交form
			form.on('submit(form-break)',function(data){
				if(_this.detail.value<0){
				  return layui.admin.ahint(2,'金额不能为负数');
				}
				var data=layui.admin.filter(_this.detail,JSON.parse(_this.old_detail));
				if(data){
					layui.admin.ajax('deposit/set_congfig',data).then(function(res){
						_this.old_detail=JSON.stringify(_this.detail);
					});
				}else{
					layer.msg('无修改');
				}
			});

			//提交form
			form.on('submit(form-commission)',function(data){
				if(_this.detail.key_value<0||_this.detail.key_value>100){
					  return layui.admin.ahint(2,'请输入0到100之间的数字');
				}
				var data=layui.admin.filter(_this.detail,JSON.parse(_this.old_detail));
				if(data){
					layui.admin.ajax('withdraw/set_congfig',data).then(function(res){
						_this.old_detail=JSON.stringify(_this.detail);
					});
				}else{
					layer.msg('无修改');
				}
			});
			
			//提交form
			form.on('submit(form-benefit)',function(data){
				if(_this.detail.key_value<0||_this.detail.key_value>100){
				  return layui.admin.ahint(2,'请输入0到100之间的数字');
				}
				var data=layui.admin.filter(_this.detail,JSON.parse(_this.old_detail));
				if(data){
					layui.admin.ajax('bonus/set_congfig',data).then(function(res){
						_this.old_detail=JSON.stringify(_this.detail);
					});
				}else{
					layer.msg('无修改');
				}
			})
	  	  },
	  	  methods:{
	  		  radioF:function(){//radio选择
	  		  	this.detail.status==1?this.detail.status=2:this.detail.status=1;
	  		  },
			  add(){
				  if(!this.full){
					  return layui.admin.ahint(2,'请输入充值金额');
				  }else if(this.full<0){
					  return layui.admin.ahint(2,'金额不能为负数');
				  }
				  /* if(!this.reduce){
					  return layui.admin.ahint(2,'请输入赠送金额');
				  } */
				  this.detail.value.push({
					  full:this.full
				  });
				  this.full='',this.reduce='';
			  },
			  save(){

				  var data=layui.admin.filter(this.detail,JSON.parse(this.old_detail)),_this=this;
					if(data){
						if(data.value)data.value=JSON.stringify(data.value);
						layui.admin.ajax('recharges/update',data).then(function(res){
							//_this.old_detail=JSON.stringify(_this.detail);
							layui.view.tab.refresh('/recharge/rechargelist');
						});
					}else{
						layer.msg('无修改');
					}
			  },
			  del(index){
				  this.detail.value.splice(index,1);
			  }
	  	  }
	  })
	})
</script>